package process

import (
	"fmt"
	"../../common/message"
	"encoding/json"
	"../../common/utils"
)

type SmsProcess struct {

}

func (obj *SmsProcess) SendGroupMes(content string) (err error) {
	
	var msg message.Message
	msg.Type = message.SmsMesType

	var smsMes message.SmsMes
	smsMes.Content = content
	smsMes.UserId = CurUser.UserId
	smsMes.UserStatus = CurUser.UserStatus

	data, err := json.Marshal(smsMes)
	if err != nil {
		fmt.Printf("json marshal smsMes error = %v\n", err)
		return
	}

	msg.Data = string(data)

	data, err = json.Marshal(msg)
	if err != nil {
		fmt.Printf("json marshal msg error = %v\n", err)
		return
	}

	tf := &utils.Transfer{
		Conn: CurUser.Conn,
	}

	err = tf.WritePkg(data)
	if err != nil {
		fmt.Printf("conn write data error = %v\n", err)
		return
	}
	return
}